<?
$con_product_picture_size = 0;
?>
<div class="navigate">
	<div class="L"></div>
    <div class="C">
    	<a class="home" href="<?=$con_root_path?>" lang="<?=$array_lang[$lang_id][0]?>">Trang chủ</a>
        <img src="<?=$theme_imagepath?>navigate_icon.gif" /><span><?=$current_cat['cat_name']?></span>
	</div>
    <div class="R"></div>
</div>
<div class="module_top"><div class="fl"></div><div class="fr"></div></div>
<div class="padding module_larger_border">
<? if ($total_record == 0){?>
	<div class="data_is_updating" lang="<?=$array_lang[$lang_id][0];?>"><?=tdt('San_pham_dang_duoc_cap_nhat');?>!</div>
<? } else {?>
	<div class="product_option_select">
    	<div class="fl">
        	<b gTrans="<?=$array_lang[$lang_id][0]?>">Có <span class="count"><?=$total_record?></span> sản phẩm</b>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            <b><span lang="<?=$array_lang[$lang_id][0]?>">Hiển thị</span> :</b>&nbsp; <? if ($show == 0) {?><span class="current" lang="<?=$array_lang[$lang_id][0]?>">Chi tiết</span><? } else {?><a href="<?=getURL(0,1,1,1,'show')?>&show=0" lang="<?=$array_lang[$lang_id][0]?>" onclick="save_cookie('showcolum', 0)">Chi tiết</a><? }?> | <? if ($show == 1) {?><span class="current" lang="<?=$array_lang[$lang_id][0]?>">Dạng cột rút gọn</span><? } else {?><a href="<?=getURL(0,1,1,1,'show')?>&show=1" lang="<?=$array_lang[$lang_id][0]?>" onclick="save_cookie('showcolum', 1)">Dạng cột rút gọn</a><? }?>
        </div>
        <div class="fr">
        	<?
			$arrSort = array(3 => 'Giá tăng dần',
							 4 => 'Giá giảm dần',
							 8 => 'Sản phẩm xem nhiều nhất',
							 6 => 'Sản phẩm mới nhất',
							 );
			?>
        	<select class="form_control" onchange="window.location.href='<?=getURL(0,1,1,1,'sort')?>&sort=' + this.value">
            	<option value="0" lang="<?=$array_lang[$lang_id][0]?>">--[Sắp xếp sản phẩm]--</option>
                <? foreach ($arrSort as $key => $value) {?>
                <option value="<?=$key?>" lang="<?=$array_lang[$lang_id][0]?>"<?=($key==$sort)?' selected="selected"':''?>><?=$value?></option>
                <? }?>
			</select>
		</div>
        <div class="clear"></div>
	</div>
    <form class="form" name="listudv_form" action="<?=$con_root_path?>compare.php?iCat=<?=$iCat?>" method="post" target="_blank">
    <? if ($show == 0) {?>
        <table class="product_table_list" cellpadding="0" cellspacing="0">
            <tr class="title">
                <td width="5%" colspan="2"><? /*?><center><a class="compare" href="#compare" onclick="document.listudv_form.submit()"></a></center><? */?></td>
                <td width="80%">
                	<span lang="<?=$array_lang[$lang_id][0]?>">Tên sản phẩm</span><br />
                    <?=generate_sort("asc", 1, $sort, $theme_imagepath)?>
					<?=generate_sort("desc", 2, $sort, $theme_imagepath)?>
				</td>
                <td>
                	<span lang="<?=$array_lang[$lang_id][0]?>">Giá bán</span><br />
                    <?=generate_sort("asc", 3, $sort, $theme_imagepath)?>
					<?=generate_sort("desc", 4, $sort, $theme_imagepath)?>
				</td>
            </tr>
            <?
			$No = 0;
            while ($listing = mysql_fetch_array($db_listing->result))
			{
				++$No;
				$detail_url = generate_detail_url('product', $listing['cat_id'], $listing['pro_id'], $listing['pro_name']);
			?>
            <tr class="list">
                <td class="No"><?=$No?><br /><input name="compare_check[]" type="checkbox" value="<?=$listing['pro_id']?>" /></td>
                <?
                //Get new dimensions
				if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/products_pictures/larger_' . $listing['pro_picture']))
				{
					list($width, $height) = getimagesize($_SERVER['DOCUMENT_ROOT'] . '/products_pictures/larger_' . $listing['pro_picture']);
					if ($con_product_picture_size) {
						$image_url = '/products_pictures/normal_' . $listing['pro_picture'];
					} else {
						$image_url = '/products_pictures/small_' . $listing['pro_picture'];
					}
					$fullsize_image_url = '/products_pictures/' . $listing['pro_picture'];
				}
				else
				{
					$width = 0;
					$height = 0;
					$image_url = $gs_imagepath . 'no_photo_small.gif';
					$fullsize_image_url = $gs_imagepath . 'no_photo_larger.gif';
				}
				?>
                <td align="center">
                	<div class="<?=($con_product_picture_size)?'product_picture_140x140':'product_picture'?>"><center><span><a class="product_picture_thumbnail" title="<?=$listing['pro_name']?>" href="<?=$detail_url?>" rel="<img src='<?=$fullsize_image_url?>' width='<?=$width?>' height='<?=$height?>' />" style="background:url(<?=$image_url?>) no-repeat center center"></a></span></center></div>
				</td>
                <td valign="top">
                	<div class="product_name"><a href="<?=$detail_url?>"><?=$listing['pro_name']?></a></div>
                    <div id="id_text_<?=$listing['pro_id']?>" class="product_teaser product_teaser_close"><?=$listing['pro_teaser']?></div>
                    <? if (strlen($listing['pro_teaser']) > 200) {?>
                    <div class="product_teaser_bnt">
                    	<div id="id_nut_open_<?=$listing['pro_id']?>" class="open"><a href="javascript:open_teaser('id_text_<?=$listing['pro_id']?>', 'id_nut_open_<?=$listing['pro_id']?>', 'id_nut_close_<?=$listing['pro_id']?>')" rel="nofollow" lang="<?=$array_lang[$lang_id][0]?>">Mở rộng</a></div>
                    	<div id="id_nut_close_<?=$listing['pro_id']?>" class="close" style="display:none"><a href="javascript:close_teaser('id_text_<?=$listing['pro_id']?>', 'id_nut_open_<?=$listing['pro_id']?>', 'id_nut_close_<?=$listing['pro_id']?>')" rel="nofollow" lang="<?=$array_lang[$lang_id][0]?>">Thu nhỏ</a></div>
					</div>
                    <? }?>
				</td>
                <td>
                    <div class="product_price"><div class="price"><?=($listing['pro_price'] > 0)?format_number($listing['pro_price']) . ' VNĐ':$con_message_zero_price?></div></div>
                    <? if ($listing['pro_price'] > 0) {?>
                    <div class="add_to_cart"><a title="Mua hàng" href="<?=$con_root_path?>addtocart.php?iPro=<?=$listing['pro_id']?>return=<?=base64_encode(getURL(0,1,1,1))?>" lang="<?=$array_lang[$lang_id][0]?>">Mua hàng</a></div>
                    <? }?>
                </td>
            </tr>
            <?
			}
			?>
        </table>
	<? } else {?>
    	<table class="product_table_thumbnail" cellpadding="0" cellspacing="0">
        <?
		$No = 0;
		while (($listing = mysql_fetch_array($db_listing->result)) || ($No % 3 != 0))
		{
			++$No;
			$detail_url = generate_detail_url('product', $listing['cat_id'], $listing['pro_id'], $listing['pro_name']);
		?>
        <? if ($No % 3 == 1) echo '<tr>';?>
            <td width="33%">
            <? if (isset($listing['pro_name'])) {?>
			<?
            //Get new dimensions
            if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/products_pictures/larger_' . $listing['pro_picture']))
            {
                list($width, $height) = getimagesize($_SERVER['DOCUMENT_ROOT'] . '/products_pictures/larger_' . $listing['pro_picture']);
				if ($con_product_picture_size) {
					$image_url = '/products_pictures/normal_' . $listing['pro_picture'];
				} else {
					$image_url = '/products_pictures/small_' . $listing['pro_picture'];
				}
				$fullsize_image_url = '/products_pictures/' . $listing['pro_picture'];
            }
            else
            {
                $width = 0;
                $height = 0;
                $image_url = $gs_imagepath . 'no_photo_small.gif';
				$fullsize_image_url = $gs_imagepath . 'no_photo_larger.gif';
            }
            ?>
            <div class="<?=($con_product_picture_size)?'product_picture_140x140':'product_picture'?>"><center><span><a class="product_picture_thumbnail" title="<?=$listing['pro_name']?>" href="<?=$detail_url?>" rel="<img src='<?=$fullsize_image_url?>' width='<?=$width?>' height='<?=$height?>' />" style="background:url(<?=$image_url?>) no-repeat center center"></a></span></center></div>
            <div class="product_name"><a href="<?=$detail_url?>"><?=$listing['pro_name']?></a></div><div class="product_price"><font lang="<?=$array_lang[$lang_id][0]?>">Giá</font>: <span class="price"><?=($listing['pro_price'] > 0)?format_number($listing['pro_price']) . ' VNĐ':$con_message_zero_price?></span></div>
            <? if ($listing['pro_price'] > 0) {?>
            <div class="add_to_cart"><center><a title="Mua hàng" href="<?=$con_root_path?>addtocart.php?iPro=<?=$listing['pro_id']?>&return=<?=base64_encode(getURL(0,1,1,1))?>" lang="<?=$array_lang[$lang_id][0]?>">Mua hàng</a></center></div>
            <? }?>
            <? /*?><div class="product_compare"><input id="compare_check_<?=$No?>" name="compare_check[]" type="checkbox" value="<?=$listing['pro_id']?>" /><a href="#compare" onclick="document.getElementById('compare_check_<?=$No?>').checked=true;document.listudv_form.submit();" lang="<?=$array_lang[$lang_id][0]?>">So sánh</a></div><? */?>
            <? }?>
            </td>
        <? if ($No % 3 == 0) echo '</tr>';?>
        <?
		}
		?>
		</table>
    <? }?>
    </form>
    <div class="break_module"></div>
    <? if($total_record > $page_size){?>
    <div class="page_div"><?=generatePageBar($page_prefix, $current_page, $page_size, $total_record, $url, $normal_class, $selected_class, $previous, $next, $first, $last, $break_type)?></div>
    <? }?>
<? }?>
</div>
<div class="module_bottom"><div class="fl"></div><div class="fr"></div></div>